//
//  P1135BFS.cpp
//  Algorithm
//
//  Created by 刘锦程 on 2023/9/7.
//

#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<queue>
using namespace std;
int n,A,B;
struct node{
    int fn;
    int step;
    node(int a,int b){
        fn=a;
        step=b;
    }
};
int book[202];
queue<node>q;
int fl[202];
void input(){
    scanf("%d",&n);
    scanf("%d%d",&A,&B);
    for(int i=1;i<=n;i++){
        scanf("%d",&fl[i]);
    }
}

void bfs(int f){
    q.push(node(f,0));
    book[f]=1;
    node nowf(0,0);
    while(!q.empty()){
        nowf=q.front();
        if(nowf.fn==B) break;
        q.pop();
        if(nowf.fn+fl[nowf.fn]<=n&&!book[nowf.fn+fl[nowf.fn]]){
            q.push(node(nowf.fn+fl[nowf.fn],nowf.step+1));
            book[nowf.fn+fl[nowf.fn]]=1;
        }
        if(nowf.fn-fl[nowf.fn]>=1&&!book[nowf.fn-fl[nowf.fn]]){
            q.push(node(nowf.fn-fl[nowf.fn],nowf.step+1));
            book[nowf.fn-fl[nowf.fn]]=1;
        }
        
    }
    if(nowf.fn==B) cout<<nowf.step;
    else cout<<-1;
}
int main(){
    input();
    bfs(A);
}
